<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;

class CreateOrderUserorderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_userorder', function (Blueprint $table) {
            $table->increments('id');
            $table->string('uid', 32)->default(Uuid::uuid1()->getHex());
            $table->decimal('order_price', 8, 2);
            $table->unsignedTinyInteger('isRecharge')->default(0);
            $table->decimal('history_meal_supplement_balance', 8, 2);
            $table->unsignedInteger('meal_supplement_balance_id');
            $table->foreign('meal_supplement_balance_id')
                ->references('id')->on('meal_supplement_balance')
                ->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_userorder');
    }
}
